package com.zhiwei.configuration;

import com.zhiwei.vo.SysResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLException;

//全局异常的处理，返回值为json
@RestControllerAdvice
public class MyExceptionConfig {
    @ExceptionHandler({RuntimeException.class, SQLException.class})
    public Object Handler(Exception e){
//        将报错信息控制台打印
        e.printStackTrace();
        return SysResult.fail();
    }
}

